package com.wx.service.impl;

import com.wx.dao.InDao;
import com.wx.dao.impl.InDaoImpl;
import com.wx.domain.Drug;
import com.wx.domain.In;
import com.wx.service.InService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class InServiceImpl implements InService {
    private InDao inDao=new InDaoImpl();

    @Override
    public void addDrugNumber(String drugId, String doctorId, int inNumber, String inDate) {
        inDao.addDrugNumber(drugId,doctorId,inNumber,inDate);
    }

    @Override
    public Map<String, Object> getInList(String pageIndex, String pageSize) {
        Map<String, Object> map=new HashMap<>();
        int count = inDao.getCount();
        List<In> inList =inDao.getInList(pageIndex,pageSize);
        map.put("pageTotal",count);
        map.put("list",inList);
        return map;
    }

    @Override
    public Map<String, Object> findIn(String searchType, String searchData, int pageIndex, int pageSize) {
        List<In> inList=null;
        int count = 0;
        if ("药品Id".equals(searchType)){
            count = inDao.getCountByDrugId(searchData);
            inList = inDao.getInListByDrugId(searchData,pageIndex,pageSize);
        }else {
            count = inDao.getCountByDoctorId(searchData);
            inList = inDao.getInListByDoctorId(searchData,pageIndex,pageSize);
        }
        Map<String, Object> map = new HashMap<>();
        map.put("pageTotal",count);
        map.put("list",inList);
        return map;
    }
}
